﻿using System;
using Microsoft.Xna.Framework;

namespace Syngine.Graphics
{
	/// <summary>
	/// 
	/// </summary>
	public static class GraphicsSettings
	{
		#region Fields



		#endregion

		#region Constructors

		static GraphicsSettings()
		{
		}

		#endregion

		#region Properties

		public static event Action<GraphicsDeviceManager> SettingsChanged;

		/// <summary>
		/// Gets the <see cref="GraphicsDeviceManager"/>.
		/// </summary>
		/// <value>The  <see cref="GraphicsDeviceManager"/>.</value>
		public static GraphicsDeviceManager Graphics
		{
			get
			{
				return GameContext.GameController.GraphicsDeviceManager;
			}
		}

		#endregion

		#region Methods

		/// <summary>
		/// Sets the supported orientations.
		/// </summary>
		/// <param name="displayOrientation">The display orientation.</param>
		/// <exception cref="System.NotImplementedException"></exception>
		public static void SetSupportedOrientations(DisplayOrientation displayOrientation)
		{
			Graphics.SupportedOrientations = displayOrientation;
		}

		/// <summary>
		/// Sets the resolution.
		/// </summary>
		/// <param name="width">The width.</param>
		/// <param name="height">The height.</param>
		public static void SetResolution(int width, int height)
		{
			Graphics.PreferredBackBufferWidth = width;
			Graphics.PreferredBackBufferHeight = height;
		}

		/// <summary>
		/// Sets the full screen.
		/// </summary>
		/// <param name="fullScreen">if set to <c>true</c> [full screen].</param>
		public static void SetFullScreen(bool fullScreen)
		{
			Graphics.IsFullScreen = fullScreen;
		}

		/// <summary>
		/// Sets the multisampling.
		/// </summary>
		/// <param name="enable">if set to <c>true</c> [enable].</param>
		public static void SetMultisampling(bool enable)
		{
			Graphics.PreferMultiSampling = enable;
		}

		/// <summary>
		/// Sets the V sync.
		/// </summary>
		/// <param name="enable">if set to <c>true</c> [enable].</param>
		public static void SetVSync(bool enable)
		{
			Graphics.SynchronizeWithVerticalRetrace = enable;
		}

		/// <summary>
		/// Toggles the full screen.
		/// </summary>
		public static void ToggleFullScreen()
		{
			Graphics.ToggleFullScreen();
		}

		/// <summary>
		/// Applies the changes.
		/// </summary>
		public static void ApplyChanges()
		{
			Graphics.ApplyChanges();

			if (SettingsChanged != null)
			{
				SettingsChanged(Graphics);
			}
		}

		#endregion
	}
}